import { Base } from '../../utils/base.js'

class Cart extends Base {
    constructor() {
        super()
    }
    // 获取购物车
    getCart(params, callback){
        var url = '/purchase/cart/get';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    // 删除购物车商品
    deleteCart(params, callback) {
        var url = '/purchase/cart/remove';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    // 修改购物车
    upadateCart(params,callback){
        var url = '/purchase/cart/modify';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    // 获取商品信息
    getGoodsById(params, callback) {
        var url = '/purchase/goods/getGoodsById';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    // 创建订单
    createOrderAndDetails(params, callback) {
        var url = '/purchase/order/createOrderAndDetails';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    commonRequest(url, reType, params, callback) {
        var that = this;
        var param = {
            url: url,
            type: reType,
            data: params,
            sCallback: function (data) {
                typeof callback == 'function' && callback(data);
            },
            eCallback: data => {
                callback && callback({ status: false });
            }
        };
        this.request(param);
    }


}
module.exports = {
  Cart
}